import { AddFormatFunc, tryCatchRuleType } from "../types";

AddFormatFunc<tryCatchRuleType>({

	type: "TRY",

	handle: (rule, FMC) => {
		return `try{\n${rule[1].map(item => FMC(item)).join("\n")}\n}${rule[2].map(item => `\ncatch(${FMC(item[1])}){\n${item[2].map(info => FMC(info)).join("\n")}\n}`).join("")}${rule[3].length === 0 ? "" : `\nfinally{\n${rule[3][1].map(item => FMC(item)).join("\n")}\n}`}`;
	},

})
